﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GA.Shared.Interfaces;
using System.Windows;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabaseProjectType : DatabaseObject
    {
        /// <summary>
        /// Identifies the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabaseProjectType),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Name Property.
        /// </summary>
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register(
                "Name",
                typeof(string),
                typeof(DatabaseProjectType),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the FacilityTypeId Property.
        /// </summary>
        public static readonly DependencyProperty FacilityTypeIdProperty =
            DependencyProperty.Register(
                "FacilityTypeId",
                typeof(int),
                typeof(DatabaseProjectType),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the Facility Property.
        /// </summary>
        public static readonly DependencyProperty FacilityTypeProperty =
            DependencyProperty.Register(
                "FacilityType",
                typeof(FacilityType),
                typeof(DatabaseProjectType),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the WorkRequired Property.
        /// </summary>
        public static readonly DependencyProperty WorkRequiredProperty =
            DependencyProperty.Register(
                "WorkRequired",
                typeof(int),
                typeof(DatabaseProjectType),
                new PropertyMetadata(0));

        /// <summary>
        /// Identifies the ItemTypeIdProduced Property.
        /// </summary>
        public static readonly DependencyProperty ItemTypeIdProducedProperty =
            DependencyProperty.Register(
                "ItemIdProduced",
                typeof(int),
                typeof(DatabaseProjectType),
                new PropertyMetadata(-1));

        /// <summary>
        /// Identifies the ItemTypeProduced Property.
        /// </summary>
        public static readonly DependencyProperty ItemTypeProducedProperty =
            DependencyProperty.Register(
                "ItemTypeProduced",
                typeof(ItemType),
                typeof(DatabaseProjectType),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the ItemsRequired Property.
        /// </summary>
        public static readonly DependencyProperty ItemsRequiredProperty =
            DependencyProperty.Register(
                "ItemsRequired",
                typeof(ObservableCollection<KeyValuePair<ItemType, int>>),
                typeof(DatabaseProjectType),
                new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsKey = true, IsIdentity = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        
        [DatabaseField("Name", IsKey = true, IsQuoted = true)]
        public string Name
        {
            get { return (string)SafeGetValue(NameProperty); }
            set { SafeSetValue(NameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the FacilityType Id.
        /// </summary>
        
        [DatabaseField("FacilityTypeId")]
        public int FacilityTypeId
        {
            get { return (int)SafeGetValue(FacilityTypeIdProperty); }
            set { SafeSetValue(FacilityTypeIdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the FacilityType.
        /// </summary>
        
        public FacilityType FacilityType
        {
            get { return (FacilityType)SafeGetValue(FacilityTypeProperty); }
            set { SafeSetValue(FacilityTypeProperty, value); }
        }

        /// <summary>
        /// Gets or sets the WorkRequired.
        /// </summary>
        
        [DatabaseField("WorkRequired")]
        public int WorkRequired
        {
            get { return (int)SafeGetValue(WorkRequiredProperty); }
            set { SafeSetValue(WorkRequiredProperty, value); }
        }

        /// <summary>
        /// Gets or sets the ItemType Id.
        /// </summary>
        
        [DatabaseField("ItemTypeIdProduced")]
        public int ItemTypeIdProduced
        {
            get { return (int)SafeGetValue(ItemTypeIdProducedProperty); }
            set { SafeSetValue(ItemTypeIdProducedProperty, value); }
        }

        /// <summary>
        /// Gets or sets the ItemType Produced.
        /// </summary>
        
        public ItemType ItemTypeProduced
        {
            get { return (ItemType)SafeGetValue(ItemTypeProducedProperty); }
            set { SafeSetValue(ItemTypeProducedProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Items Required.
        /// </summary>
        
        public ObservableCollection<KeyValuePair<ItemType, int>> ItemsRequired
        {
            get { return (ObservableCollection<KeyValuePair<ItemType, int>>)SafeGetValue(ItemsRequiredProperty); }
            set { SafeSetValue(ItemsRequiredProperty, value); }
        }

        public DatabaseProjectType()
        {
        }

        public DatabaseProjectType(LinkedDependencyObject baseObject)
            : base(baseObject)
        {
        }

        public DatabaseProjectType(LinkedDependencyObject baseObject, BindingMode bindingMode)
            : base(baseObject, bindingMode)
        {
        }

        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
